package com.hzhk.happyrent.ui.adapter.viewpager;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hzhk.happyrent.R;
import com.hzhk.happyrent.network.HttpManager;

/**
 * User: hzhk(1097282555@qq.com)
 * Date: 2017/11/21
 * Time: 15:28
 * progject: HappyRent
 * Describe： ${Describe}
 */
public class GuideAdapter extends PagerAdapter{
    private Context context;
    private int[] images=new int[]{R.drawable.guide1,R.drawable.guide2,R.drawable.guide3};
    public GuideAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view.equals(object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView imageView=new ImageView(context);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setImageDrawable(context.getResources().getDrawable(images[position]));
        container.addView(imageView);
        return imageView;
    }
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
        object = null;
    }
}
